package 力扣._455分发饼干;

import java.util.Arrays;

public class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int i = g.length - 1;
        int j = s.length - 1;
        int sum = 0;
        while (i >= 0 && j >= 0) {
            if (g[i] <= s[j]) {
                i--;
                j--;
                sum++;
            } else
                i--;
        }
        return sum;
    }
}
